﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MapWindow.DirectX;

namespace MapWindow3DTest
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
            map1.MouseMoveGeographic += new EventHandler<MouseMoveArgs>(map1_MouseMove);
            this.FormClosing += new FormClosingEventHandler(frmMain_FormClosing);
            //map1.CursorMode = MapWindow.Components.ToolModes.None;
        }

      

     
       
        void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            map1.Close();
        }

        void map1_MouseMove(object sender, MouseMoveArgs e)
        {
           
        
            //mwStatusStrip1.Progress("", 0, "X: " + e.X.ToString() + ", Y: " + e.Y.ToString());
            statusLabel.Text = "X: " + e.X.ToString() + ", Y: " + e.Y.ToString() + ", Z: " + e.Z.ToString() + "XSpan: " + map1.Camera.DrawBox.XSpan.ToString();
            mwStatusStrip1.Invalidate();
         
            //System.Diagnostics.Debug.WriteLine("X: " + e.X.ToString() + ", Y: " + e.Y.ToString());
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            map1.OpenLayer();
        }

        private void openFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            map1.OpenFolder(@"C:\Program Files\NASA\World Wind 1.4\Cache\BMNG\BMNG (Shaded + Bathymetry) Tiled - 6.2004");
           // map1.OpenFolder();
        }

        private void openModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "*.x|*.x|All Files(*.*)|*.*";
            if (ofd.ShowDialog(this) != DialogResult.OK) return;
            MapWindow.DirectX.Data.MeshModelDX mod = new MapWindow.DirectX.Data.MeshModelDX(ofd.FileName);
            MapWindow.DirectX.ModelLayerDX lyr = new MapWindow.DirectX.ModelLayerDX(mod);
            map1.Layers.Add(lyr);
           
        }

        private void mwStatusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

       
       
    }
}
